#include "FontSizeComboBox.h"

/**
 * @class FontSizeComboBox
 * @note This widget provides point font size only.
 */
FontSizeComboBox::FontSizeComboBox(QWidget* parent)
    : QComboBox(parent)
{
    initItems();
}

//! @private
void FontSizeComboBox::initItems()
{
    clear();
    QStringList fontSizes;
    fontSizes << "6" << "7" << "8" << "9" << "10" << "11" << "12" << "14" << "16"
              << "18" << "20" << "22" << "24" << "26" << "28" << "36" << "48" << "72";
    addItems(fontSizes);
}

int FontSizeComboBox::fontSize()
{
   return currentText().toInt();
}

void FontSizeComboBox::setFontSize(int value)
{
    if (fontSize() != value) {
        int index = findText(QString("%1").arg(value), Qt::MatchFixedString);
        setCurrentIndex(index > -1 ? index : 0);
    }
}
